﻿using System;
using UnityEngine;

// Token: 0x02000295 RID: 661
public class AIRaygun : AIGun
{
	// Token: 0x170001B9 RID: 441
	// (get) Token: 0x06000EAC RID: 3756 RVA: 0x00003781 File Offset: 0x00001981
	public override int AnimGunType
	{
		get
		{
			return 1;
		}
	}

	// Token: 0x170001BA RID: 442
	// (get) Token: 0x06000EAD RID: 3757 RVA: 0x00003781 File Offset: 0x00001981
	public override int AnimLayer
	{
		get
		{
			return 1;
		}
	}

	// Token: 0x170001BB RID: 443
	// (get) Token: 0x06000EAE RID: 3758 RVA: 0x00070914 File Offset: 0x0006EB14
	public override string AnimTransitionName
	{
		get
		{
			return "Raygun Aim Layer.Idle -> Raygun Aim Layer.Aiming";
		}
	}

	// Token: 0x06000EAF RID: 3759 RVA: 0x0007091B File Offset: 0x0006EB1B
	protected override void Start()
	{
		this.defaultFiringAudioClip = SoundManager.This.npcRaygunProjFireSound;
		base.Start();
		this.SetupParticlesForSingleFire();
	}

	// Token: 0x06000EB0 RID: 3760 RVA: 0x00070939 File Offset: 0x0006EB39
	public override void SetColor(int r, int g, int b)
	{
		base.SetColor(r, g, b);
		this.SetupParticlesForSingleFire();
	}

	// Token: 0x06000EB1 RID: 3761 RVA: 0x0007094C File Offset: 0x0006EB4C
	private void UpdateGradient()
	{
		Color projectileColor;
		if (this.projectileColor == Color.clear)
		{
			projectileColor = new Color(GlobalPreferences.AIRaygunColorR.value, GlobalPreferences.AIRaygunColorG.value, GlobalPreferences.AIRaygunColorB.value);
		}
		else
		{
			projectileColor = this.projectileColor;
		}
		this.shotEmitterParticlesGradient.SetKeys(new GradientColorKey[]
		{
			new GradientColorKey(projectileColor, 0f),
			new GradientColorKey(projectileColor, 1f)
		}, new GradientAlphaKey[]
		{
			new GradientAlphaKey(0f, 0f),
			new GradientAlphaKey(1f, 0.5f),
			new GradientAlphaKey(0f, 1f)
		});
	}

	// Token: 0x06000EB2 RID: 3762 RVA: 0x00070A38 File Offset: 0x0006EC38
	private void SetupParticlesForSingleFire()
	{
		this.UpdateGradient();
		this.shotEmitterParticles.colorOverLifetime.color = this.shotEmitterParticlesGradient;
	}

	// Token: 0x06000EB3 RID: 3763 RVA: 0x00070A69 File Offset: 0x0006EC69
	public override void Fire()
	{
		this.Fire(0f);
	}

	// Token: 0x06000EB4 RID: 3764 RVA: 0x00070A78 File Offset: 0x0006EC78
	public override void Fire(float inaccurracyFactor)
	{
		float x = this.owner.transform.localScale.x;
		Vector3 position = this.firingPoint.position + this.firingPoint.forward * x;
		GameObject gameObject = UnityEngine.Object.Instantiate<GameObject>(this.projectilePrefab, position, base.transform.rotation);
		if (inaccurracyFactor > 0f)
		{
			gameObject.transform.Rotate(UnityEngine.Random.Range(0f, inaccurracyFactor), UnityEngine.Random.Range(0f, inaccurracyFactor), 0f);
		}
		AIRaygunProjectile component = gameObject.GetComponent<AIRaygunProjectile>();
		if (this.projectileColor != Color.clear)
		{
			component.Initialize(this.owner.GetComponent<EntityBase>(), this.projectileSpeedMult, x * this.projectileScaleMult, this.projectileColor);
		}
		else
		{
			component.Initialize(this.owner.GetComponent<EntityBase>(), this.projectileSpeedMult, x * this.projectileScaleMult);
		}
		if (this.customProjectileImpactAudioClip != null)
		{
			component.SetSoundClip(this.customProjectileImpactAudioClip);
		}
		this.shotEmitterParticles.transform.localScale = Vector3.one * x;
		this.shotEmitterParticles.Emit(20);
		this.firingAudioSource.Play();
	}

	// Token: 0x040013BC RID: 5052
	private Gradient shotEmitterParticlesGradient = new Gradient();

	// Token: 0x040013BD RID: 5053
	[SerializeField]
	private ParticleSystem shotEmitterParticles;
}
